package com.xingdata.jjxc.adapter;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.sax.StartElementListener;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xingdata.jjxc.R;
import com.xingdata.jjxc.activity.VideoUploadActivity;
import com.xingdata.jjxc.activity.VideoActivity;
import com.xingdata.jjxc.enty.VoideEntity;
import com.xingdata.jjxc.utils.SDCardTools;

public class VoideAdp extends BaseAdapter {
	private List<VoideEntity> entities;
	private VoideEntity entity;
	private LayoutInflater inflater;
	private Context context;


	public VoideAdp(FragmentActivity activity, List<VoideEntity> entities2) {
		this.entities = entities2;
		this.context = activity;
	}

	@Override
	public int getCount() {
		return entities == null ? 0 : entities.size();
	}

	@Override
	public VoideEntity getItem(int position) {
		// TODO Auto-generated method stub
		return entities.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder mholder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.splendid, null);
			mholder = new Holder();
			mholder.splendidview = (ImageView) convertView
					.findViewById(R.id.splendidview);
			mholder.fTime = (TextView) convertView
					.findViewById(R.id.circulationdate);
			mholder.fSize = (TextView) convertView.findViewById(R.id.flow);
			mholder.splendidview.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					switch (v.getId()) {
					case R.id.splendidview:
						Intent intent = new Intent(context,
								VideoUploadActivity.class);
						context.startActivity(intent);
						break;
					}
				}
			});

			convertView.setTag(mholder);
		} else {
			mholder = (Holder) convertView.getTag();
		}
		entity = entities.get(position);
		mholder.fTime.setText(entity.getfTime());
		mholder.fSize.setText(entity.getfSize());

		return convertView;
	}

	class Holder {
		private ImageView splendidview;
		private TextView fTime, fSize;
	}

	// class TextviewOnClickListener implements OnClickListener {
	// int position;
	//
	// public TextviewOnClickListener(int position) {
	// this.position = position;
	// }
	//
	// @Override
	// public void onClick(View v) {
	// Intent intent = new Intent(context, FindallPost_videoActivity.class);
	// context.startActivity(intent);
	// }
	//
	// }
}
